package cn.com.dycc.party_org.organize.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.dycc.common.controller.BaseController;
import cn.com.dycc.party_org.organize.entity.OrganizeEntity;
import cn.com.dycc.party_org.organize.entity.OrganizeUserInfo;
import cn.com.dycc.party_org.organize.param.OrganizeParam;
import cn.com.dycc.party_org.organize.param.PartyInfoParam;
import cn.com.dycc.party_org.organize.service.OrganizeService;
import cn.com.dycc.util.JsonObjectResult;
/**
 * 党组织管理控制层
 * @author linfa
 *
 */
@Controller
@RequestMapping("/organize")
public class OrganizeController extends BaseController{

	@Resource(name="organizeService")
	private OrganizeService organizeService;
	
	//增加党组织
	@RequestMapping("/add.do")
	@ResponseBody
	public JsonObjectResult addDeptParty(HttpServletRequest request,OrganizeParam organizeParam){
		String mes = organizeService.addDeptParty(request, organizeParam);
		return new JsonObjectResult(mes);
	}
	
	//查查询所有显示党组织树 用于点击后弹出的党组织树 HttpServletRequest request 和人员的通讯录,
	@RequestMapping("/findorguser.do")
	@ResponseBody
	public JsonObjectResult findOrganizeUser(HttpServletRequest request,PartyInfoParam partyInfoParam){
		OrganizeUserInfo oui = organizeService.findOrganizeUser(request, partyInfoParam);
		return new JsonObjectResult(oui);
	}
	
	//查询所有显示党组织树
	@RequestMapping("/partree.do")
	@ResponseBody
	public JsonObjectResult findListPartyInfo(HttpServletRequest request,PartyInfoParam partyInfoParam){
		List<Object> list = organizeService.findListPartyInfo(request, partyInfoParam);
		return new JsonObjectResult(list);
	}
	
	//显示党组织树，用于用户的党组织显示
	@RequestMapping("/orgtree.do")
	@ResponseBody
	public JsonObjectResult findListOrganiTree(HttpServletRequest request,PartyInfoParam partyInfoParam){
		List<Object> list = organizeService.findListOrganiTree(request, partyInfoParam);
		return new JsonObjectResult(list);
	}
	
	//根据id查询党组织信息
	@RequestMapping("/findbyid.do")
	@ResponseBody
	public JsonObjectResult findOrganizeByDeptId(HttpServletRequest request,String dept_id){
		OrganizeEntity organizeEntity = organizeService.findOrganizeByDeptId(request,dept_id);
		return new JsonObjectResult(organizeEntity);
	}
	
	//更新党组织
	@RequestMapping("/update.do")
	@ResponseBody
	public JsonObjectResult updateOrganize(HttpServletRequest request,OrganizeParam organizeParam){
		String mes = organizeService.updateOrganize(request, organizeParam);
		return new JsonObjectResult(mes);
	}
	
	//根据党组织id删除党组织信息
	@RequestMapping("/delbyid.do")
	@ResponseBody
	public JsonObjectResult deleteOrganize(HttpServletRequest request,String dept_id){
		String mes = organizeService.deleteOrganize(request, dept_id);
		return new JsonObjectResult(mes);
	}
	
	//显示党组织列表
	@RequestMapping("/orgline.do")
	@ResponseBody
	public JsonObjectResult findListOrganiLine(HttpServletRequest request,PartyInfoParam partyInfoParam){
		List<Object> list = organizeService.findListOrganiLine(request, partyInfoParam);
		return new JsonObjectResult(list);
	}
	
	//显示党组织列表
	@RequestMapping("/orgchecktree.do")
	@ResponseBody
	public JsonObjectResult findListCheckTree(HttpServletRequest request,PartyInfoParam partyInfoParam,String[] listDeptId){
		List<Object> list = organizeService.findListCheckTree(request, partyInfoParam,listDeptId);
		return new JsonObjectResult(list);
	}
	
	//显示党组织树，父可以查子，子不能查父
	@RequestMapping("/treebypid.do")
	@ResponseBody
	public JsonObjectResult findTreeByPid(HttpServletRequest request,PartyInfoParam partyInfoParam,String[] listDeptId){
		List<Object> list = organizeService.findTreeByPid(request, partyInfoParam,listDeptId);
		return new JsonObjectResult(list);
	}
	
	
	
	
}
